<!-- subpkg_consult/room/components/patient-info.vue -->
<script lang="ts" setup>
  import type { MsgItem, PictureElement } from '@/type/room'

  interface Props {
    msgItem: MsgItem
  }
  const props = defineProps<Props>()
  // 找医生/极速问诊-患病时间1一周内2一月内3半年内4半年以上
  const time = ['一周内', '一月内', '半年内', '半年以上']

  const onPreviewClick = (imgs: PictureElement[]) => {
    uni.previewImage({
      urls: imgs.map((item) => item.url),
    })
  }
</script>
<template>
  <!-- 患者信息（21） -->
  <view class="patient-info">
    <view class="header">
      <view class="title"
        >{{ props.msgItem.msg?.consultRecord?.patientInfo?.name }}
        {{ props.msgItem.msg?.consultRecord?.patientInfo?.genderValue }}
        {{ props.msgItem.msg?.consultRecord?.patientInfo?.age }}岁</view
      >
      <view class="note"
        >{{ time[props.msgItem.msg?.consultRecord?.illnessTime ?? 0] }} |
        {{ props.msgItem.msg?.consultRecord?.consultFlag === 0 ? '未就诊' : '就诊过' }}</view
      >
    </view>
    <view class="content">
      <view class="list-item">
        <text class="label">病情描述</text>
        <text class="note">{{ props.msgItem.msg?.consultRecord?.illnessDesc }}</text>
      </view>
      <view class="list-item">
        <text class="label">图片</text>
        <text
          class="note"
          v-if="props.msgItem.msg?.consultRecord?.pictures.length"
          @click="onPreviewClick(props.msgItem.msg?.consultRecord?.pictures)"
          >点击查看</text
        >
        <text class="note" v-else> 暂无图片</text>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
  .patient-info {
    padding: 30rpx;
    margin-top: 60rpx;
    border-radius: 20rpx;
    box-sizing: border-box;
    background-color: #fff;

    .header {
      padding-bottom: 20rpx;
      border-bottom: 1rpx solid #ededed;

      .title {
        font-size: 32rpx;
        color: #121826;
        margin-bottom: 10rpx;
      }

      .note {
        font-size: 26rpx;
        color: #848484;
      }
    }

    .content {
      margin-top: 20rpx;
      font-size: 26rpx;

      .list-item {
        display: flex;
        margin-top: 10rpx;
      }

      .label {
        width: 130rpx;
        color: #3c3e42;
      }

      .note {
        flex: 1;
        line-height: 1.4;
        color: #848484;
      }
    }
  }
</style>
